package com.sit.service.impl;

import com.sit.entity.AddAthlete;
import com.sit.entity.Athlete;
import com.sit.entity.Ca;
import com.sit.mapper.AthleteMapper;
import com.sit.mapper.CaMapper;
import com.sit.service.AddAthleteService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class AddAthleteServiceImpl implements AddAthleteService {

    @Autowired
    private AthleteMapper athleteMapper;

    @Autowired
    private CaMapper caMapper;

    @Override
    public boolean addAthlete(AddAthlete addAthlete) {
        Athlete athlete = new Athlete();
        athlete.setAn(addAthlete.getAn());
        athlete.setAno(addAthlete.getAno());
        athlete.setSex(addAthlete.getSex());
        athlete.setClassnumber(addAthlete.getClassnumber());
        athlete.setCollege(addAthlete.getCollege());
        int flag1 =athleteMapper.insert(athlete);

        Ca ca = new Ca();
        ca.setAno(addAthlete.getAno());
        ca.setCnoA(addAthlete.getCnA());
        int flag2 = caMapper.insert(ca);
        if(flag1 >0 && flag2 > 0){
            return  true;
        }else {return false;}

    }
}
